package com.example.androidcomplete0102.ch12;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.example.androidcomplete0102.R;

public class ListViewArrayList extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch12_listviewarraylist);
		
		//데이터 원본
		ArrayList<String> arGeneral = new ArrayList<>();
		arGeneral.add("김유신");
		arGeneral.add("이순신");
		arGeneral.add("강감찬");
		arGeneral.add("을지문덕");
		//String arGeneral ={"김유신", "이순신", "강감찬", "을지문덕"};
		
		//어댑터 준비
		ArrayAdapter<String> aAdapter = new ArrayAdapter<>(this, 
				android.R.layout.simple_expandable_list_item_1, 
				arGeneral);
		//어댑터를 리스트뷰에 연결
		ListView list = (ListView)findViewById(R.id.ch12_listView);
		list.setAdapter(aAdapter);
		
	}
}
